package MineGod;

import org.lwjgl.opengl.GL11;

public class Particle {

	public double life;
	
	protected double xPos;
	protected double yPos;
	
	protected double xSpeed;
	protected double ySpeed;
	
	protected double initialX;
	
	double red;
	double green;
	double blue;
	
	public Particle(double life, double xPos, double yPos, double xSpeed, double ySpeed){
		this.life = life;
		this.xPos = xPos;
		this.yPos = yPos;
		this.xSpeed = xSpeed;
		this.ySpeed = ySpeed;
		initialX = MineGod.player.xPos;
		
		this.red = Chunk.rand.nextDouble();
		this.green = Chunk.rand.nextDouble();
		this.blue = Chunk.rand.nextDouble();
		
	}
	
	public void update(int delta){
		life -= delta;
		xPos += xSpeed * delta;
		yPos += ySpeed * delta;
	}
	
	public void render(){
		double renderX = initialX-MineGod.player.xPos;
		GL11.glDisable(GL11.GL_TEXTURE_2D);
		GL11.glBegin(GL11.GL_QUADS);
			GL11.glNormal3d(0, 0, 1);
			GL11.glColor3d(red, green, blue);
			GL11.glVertex3d(renderX+xPos, yPos, -15);
			GL11.glColor3d(red, green, blue);
			GL11.glVertex3d((renderX+xPos + 4), yPos, -15);
			GL11.glColor3d(red, green, blue);
			GL11.glVertex3d((renderX+xPos + 4), (yPos+4), -15);
			GL11.glColor3d(red, green, blue);
			GL11.glVertex3d(renderX + xPos, (yPos+4), -15);
		GL11.glEnd();
	}
	
}
